<template>
	<view>
		<!-- 我的考试 -->
		<u-navbar title="我的考试" title-color="#fff" :background="background" back-icon-color="#ffffff"
			:back-text-style="{color: '#fff'}">
			<view class="slot-wrap">
				<!-- <u-icon name="list-dot" color="#ffffff" size="36" @click="changeModel"></u-icon> -->
			</view>
		</u-navbar>
		<u-search class="searchBar" placeholder="搜索考试" v-model="keyword" :clearabled="true" @search="searchFunc"
			@custom="searchFunc" :show-action="true"></u-search>
		<view class="content">
			<!-- <view>{{myExamList}}</view> -->
			<exam-card v-for="(item,index) in myExamList.records" :key="index" :examItem='item'></exam-card>
		</view>
		<u-loadmore :status="status" />
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keyword: '',
				myExamList: [],
				status: 'loadmore',
				page: 1,
				background: {
					'background-image': 'linear-gradient(45deg, #007fd1, #013cd2)'
				},
			}
		},
		methods: {
			searchFunc(keyword) {
				console.log(keyword);
				var that = this
				this.$api.getExamList(1, keyword)
					.then(res => {
						uni.showToast({
							title: '搜索成功'
						})
						that.examList = res.values.records
					})
			},
		},
		onLoad() {
			// 获取用户信息
			import("@/common/exam_myExam.js").then(myExamList => {
				this.myExamList = myExamList.myExamList
			})
			// this.$api.getExamList(1, '')
			// 	.then(res => {
			// 		console.log("考试列表:", res.values.records);
			// 		this.examList = res.values.records
			// 	})

		},
		onReachBottom() {
			// if (this.keyword == undefined) {
			// 	this.keyword = ''
			// }
			// if (this.status === 'loadmore') {
			// 	this.page += 1
			// 	this.status = 'loading'
			// 	this.$api.getExamList(this.page, this.keyword)
			// 		.then(res => {
			// 			if (res.values.records.length === 0) {
			// 				this.status = 'nomore'
			// 			} else {
			// 				this.examList = this.examList.concat(res.values.records)
			// 				this.status = 'loadmore'
			// 			}
			// 		})
			// }
		}
	}
</script>
</script>

<style lang="scss">
	.searchBar {
		padding: 20upx;
	}
</style>
